﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System.Reflection;
using System.Diagnostics;

namespace DARE.Effects.RenderEffect
{
    public class CModelEffectParam : AEffectParam
    {
        #region Properties

        public bool PerPixelLighteningEnabled
        {
            get { return GetData<bool>("PerPixelLighteningEnabled"); }
            set { SetData("PerPixelLighteningEnabled", value); }
        }

        public bool UseSceneParameters
        {
            get { return GetData<bool>("UseSceneParameters"); }
            set { SetData("UseSceneParameters", value); }    
        }

        public bool IsAnimationActive
        {
            get { return GetData<bool>("IsAnimationActive"); }
            set { SetData("IsAnimationActive", value); }
        }

        public bool IsDecalsActive
        {
            get { return GetData<bool>("IsDecalsActive"); }
            set { SetData("IsDecalsActive", value); }
        }

        public Vector3 EyePosition
        {
            get { return GetData<Vector3>("EyePosition"); }
            set { SetData("EyePosition", value); }
        }

        public bool IsMultiTexturingActive
        {
            get { return GetData<bool>("IsMultiTexturingActive"); }
            set { SetData("IsMultiTexturingActive", value); }
        }

        public float Brighteness
        {
            get { return GetData<float>("Brighteness"); }
            set { SetData("Brighteness", value); }
        }

        public bool LighteningEnabled
        {
            get { return GetData<bool>("LighteningEnabled"); }
            set { SetData("LighteningEnabled", value); }
        }

        public Color AmbientLightColor
        {
            get { return GetData<Color>("AmbientLightColor"); }
            set { SetData("AmbientLightColor", value); }
        }

        public float AmbientLightIntensity
        {
            get { return GetData<float>("AmbientLightIntensity"); }
            set { SetData("AmbientLightIntensity", value); }
        }

        public Color EmissiveLightColor
        {
            get { return GetData<Color>("EmissiveLightColor"); }
            set { SetData("EmissiveLightColor", value); }
        }

        public float EmissiveLightIntensity
        {
            get { return GetData<float>("EmissiveLightIntensity"); }
            set { SetData("EmissiveLightIntensity", value); }
        }

        public Vector3 DirectionalLight1Direction
        {
            get { return GetData<Vector3>("DirectionalLight1Direction"); }
            set { SetData("DirectionalLight1Direction", value); }
        }

        public Color DirectionalLight1DiffuseColor
        {
            get { return GetData<Color>("DirectionalLight1DiffuseColor"); }
            set { SetData("DirectionalLight1DiffuseColor", value); }
        }

        public float DirectionalLight1DiffuseIntensity
        {
            get { return GetData<float>("DirectionalLight1DiffuseIntensity"); }
            set { SetData("DirectionalLight1DiffuseIntensity", value); }
        }

        public Color DirectionalLight1SpecularColor
        {
            get { return GetData<Color>("DirectionalLight1SpecularColor"); }
            set { SetData("DirectionalLight1SpecularColor", value); }
        }

        public float DirectionalLight1SpecularIntensity
        {
            get { return GetData<float>("DirectionalLight1SpecularIntensity"); }
            set { SetData("DirectionalLight1SpecularIntensity", value); }
        }

        public Vector3 DirectionalLight2Direction
        {
            get { return GetData<Vector3>("DirectionalLight2Direction"); }
            set { SetData("DirectionalLight2Direction", value); }
        }

        public Color DirectionalLight2DiffuseColor
        {
            get { return GetData<Color>("DirectionalLight2DiffuseColor"); }
            set { SetData("DirectionalLight2DiffuseColor", value); }
        }

        public float DirectionalLight2DiffuseIntensity
        {
            get { return GetData<float>("DirectionalLight2DiffuseIntensity"); }
            set { SetData("DirectionalLight2DiffuseIntensity", value); }
        }

        public Color DirectionalLight2SpecularColor
        {
            get { return GetData<Color>("DirectionalLight2SpecularColor"); }
            set { SetData("DirectionalLight2SpecularColor", value); }
        }

        public float DirectionalLight2SpecularIntensity
        {
            get { return GetData<float>("DirectionalLight2SpecularIntensity"); }
            set { SetData("DirectionalLight2SpecularIntensity", value); }
        }

        public Vector3 DirectionalLight0Direction
        {
            get { return GetData<Vector3>("DirectionalLight0Direction"); }
            set { SetData("DirectionalLight0Direction", value); }
        }

        public Color DirectionalLight0DiffuseColor
        {
            get { return GetData<Color>("DirectionalLight0DiffuseColor"); }
            set { SetData("DirectionalLight0DiffuseColor", value); }
        }

        public float DirectionalLight0DiffuseIntensity
        {
            get { return GetData<float>("DirectionalLight0DiffuseIntensity"); }
            set { SetData("DirectionalLight0DiffuseIntensity", value); }
        }

        public Color DirectionalLight0SpecularColor
        {
            get { return GetData<Color>("DirectionalLight0SpecularColor"); }
            set { SetData("DirectionalLight0SpecularColor", value); }
        }

        public float DirectionalLight0SpecularIntensity
        {
            get { return GetData<float>("DirectionalLight0SpecularIntensity"); }
            set { SetData("DirectionalLight0SpecularIntensity", value); }
        }

        public Vector2 ColorMapOffset
        {
            get { return GetData<Vector2>("ColorMapOffset"); }
            set { SetData("ColorMapOffset", value); }
        }

        public Vector2 ColorMapTiles
        {
            get { return GetData<Vector2>("ColorMapTiles"); }
            set { SetData("ColorMapTiles", value); }
        }

        public Texture2D ColorMap
        {
            get { return GetData<Texture2D>("ColorMap"); }
            set { SetData("ColorMap", value); }
        }

        public float Alpha
        {
            get { return GetData<float>("Alpha"); }
            set { SetData("Alpha", value); }
        }

        #endregion

        #region CTOR

        public CModelEffectParam(CEffect _effect) : this(_effect, null) { }

        public CModelEffectParam(CEffect _effect, AEffectParam _parent) : base(_effect, _parent)
        {
            var _effectType = _effect.GetType();
            foreach (var _property in typeof(CModelEffectParam).GetProperties(BindingFlags.SetProperty | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public))
            {
                var _effectProperty = _effectType.GetProperty(_property.Name);
                if (_effectProperty != null && _effectProperty.CanWrite)
                {
                    _property.SetValue(this, _effectProperty.GetValue(_effect, null), null);
                }
            }
        }
        
        #endregion
    }
}
